import java.sql*;
import static java.lang.System.out;

public class ConnectionDemo{
	public static void main(String[] args){
		throws ClassNotFoundExpection,SQLExpection{
		Class.forName("com.mysql.jdbc.Driver");
		String jdbcUrl = "jdbc:mysql://localhost:3306/demo";
		String user  = "root";
		String password = "openhome";
		try(Connection conn = 
				DriverManager.getConnection(jdbUrl,user,passwd){
				out.printf("已%s数据库连机%n“，conn.isclosed()?"关闭”：“开启”);
				}
	      }
	}



